package com.dw.demo.consumer.controller;


import com.dw.demo.consumer.service.RestTemplateService;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@Slf4j
public class HelloController {

    @Autowired
    RestTemplateService helloService;

    /**
     * HystrixCommand  配置熔断返回方法
     * @return
     */
    @RequestMapping("/demo")
    @HystrixCommand(fallbackMethod = "sorry")
    public Object test(){
        return helloService.hiService();
    }

    public Object sorry(){
        return helloService.returnBaidu();
    }
}
